<?php
class Job_model extends CI_Model {
	function __construct()
	{
		parent::__construct();
	}
	
	function get_job_by_company_id($id)
	{
		$this->db->select('*');
		$this->db->from('job');
		$this->db->where('company_id',$id);
		
		$data = array();
		$q = $this->db->get();
		if ($q->num_rows() > 0) {
			foreach ($q->result() as $row)
				$data[] = $row;
		}
		return $data;
	}
	
	function get_job_by_id($id)
	{
		$this->db->select('*, job.description AS job_desc,
							company.description AS co_desc,
							job.email AS job_email,
							job.phone AS job_phone,
							job.location AS job_location');
		$this->db->from('job');
		$this->db->where('post_id',$id);
		$this->db->join('company','company.company_id = job.company_id', 'full');
		$this->db->order_by("due_date","ASC");
		
		$data = array();
		$q = $this->db->get();
		if ($q->num_rows() > 0)
			$data = $q->result();
		return $data[0];
	}
}
